package com.yhg.controller;

import com.yhg.Product.Bean.Product;
import com.yhg.service.ProductService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//@RequestMapping("/api/product")  //增加路径前缀
public class ProductController {

    @Autowired
    ProductService productService ;

    //查询商品
    @GetMapping("/product/{Id}")
    public Product getProduct(@PathVariable("Id")  Long productId, HttpServletRequest request){
        System.out.println(request.getHeader("X-Token"));
        System.out.println("hello");
        Product product = productService.getProductByProductId(productId);
        return product;
    }
}
